// 获取今天以前指定天数的开始和结束日期
// 

function formatDate(date:any) {
    var myyear = date.getFullYear();
    var mymonth = date.getMonth() + 1;
    var myweekday = date.getDate();

    if (mymonth < 10) {
        mymonth = "0" + mymonth;
    }
    if (myweekday < 10) {
        myweekday = "0" + myweekday;
    }
    return {
        time: (myyear + "/" + mymonth + "/" + myweekday),
        year: myyear,
        month: mymonth,
        day: myweekday

    };
}

export default function getDay(n:number){
    var now = new Date();
    var targetday_milliseconds = now.getTime() - (24 * 60 * 60 * 1000 * n);
    let endTimp = new Date(targetday_milliseconds); //注意，这行是关键代码
    // 获取今天的日期格式年月日
    let ed:any=formatDate(endTimp)
    let timeEd=ed.year+"-"+ed.month+"-"+ed.day
    let thisTime:any=formatDate(now)
    let thiTIme1=thisTime.year+"-"+thisTime.month+"-"+thisTime.day
    // return formatDate(endTimp)
    return {
        nowTime:thiTIme1,
        timeEd:timeEd
    }
}